#!/bin/sh

# 错误检查
set -e

# 定义项目列表

project=${1-server}
version=${2-master}

# 检查参数是否传递
if [ -z "$project" ]; then
  echo "请输入项目名称$project"
  exit 1
fi

echo 创建项目/root/${project}
mkdir -p /root/${project}
cd /root/${project}

GITEE_URL="https://gitee.com/kelc/release/raw/master"
files="prepare.sh compose.sh"
echo "下载$files"
# 迭代文件列表并下载文件
for file in $files;do
    wget -qO "$file" "$GITEE_URL/$file"
done

echo "项目/root/$project 初始化完成"
echo 检查/安装docker及docker-compose环境:sh prepare.sh
sh prepare.sh
echo 下载配置文件及部署应用:sh compose.sh
sh compose.sh deploy ${version}